package com.vietnam.power.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.vietnam.power.persitence.ArticleGroup;

public class Article {
	private Integer id;
	private Date createdDate;
	private String description;
	private String embededMap;
	private String keyword;
	private String name;
	private String shortDescription;
	private UserInfo userInfo;
	private long totalPage;
	List<Integer> articleImages;
	private int articelGroupId;
	private String articleGroupDesc;
	private String articleGroupName;
	private String email;
	private String password;

	public Article() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getEmbededMap() {
		return this.embededMap;
	}

	public void setEmbededMap(String embededMap) {
		this.embededMap = embededMap;
	}

	public String getKeyword() {
		return this.keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getShortDescription() {
		return this.shortDescription;
	}

	public void setShortDescription(String shortDescription) {
		this.shortDescription = shortDescription;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

	public UserInfo getUserInfo() {
		return userInfo;
	}

	public long getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(long totalPage) {
		this.totalPage = totalPage;
	}

	public List<Integer> getArticleImages() {
		if (articleImages == null) {
			articleImages = new ArrayList<Integer>();
		}
		return articleImages;
	}

	public void setArticleImages(List<Integer> articleImages) {
		this.articleImages = articleImages;
	}

	public int getArticelGroupId() {
		return articelGroupId;
	}

	public void setArticelGroupId(int articelGroupId) {
		this.articelGroupId = articelGroupId;
	}

	public String getArticleGroupDesc() {
		return articleGroupDesc;
	}

	public void setArticleGroupDesc(String articleGroupDesc) {
		this.articleGroupDesc = articleGroupDesc;
	}

	public String getArticleGroupName() {
		return articleGroupName;
	}

	public void setArticleGroupName(String articleGroupName) {
		this.articleGroupName = articleGroupName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void convertToDomain(com.vietnam.power.persitence.Article art) {
		this.id = art.getId();
		this.name = art.getName();
		this.keyword = art.getKeyword();
		this.createdDate = art.getCreatedDate();
		this.description = art.getDescription();
		this.embededMap = art.getEmbededMap();
		this.shortDescription = art.getShortDescription();
		this.userInfo = new UserInfo();
		this.userInfo.setId(art.getUserInfo().getId());
		this.userInfo.setFirstName(art.getUserInfo().getFirstName());
		this.userInfo.setLastName(art.getUserInfo().getLastName());
		this.articelGroupId = art.getArticleGroup().getId();
		this.articleGroupDesc = art.getArticleGroup().getDescription();
		this.articleGroupName = art.getArticleGroup().getName();
		this.email = art.getEmail();
		this.password = art.getPassword();
		for (com.vietnam.power.persitence.ArticleImage img : art.getArticleImages()) {
			getArticleImages().add(img.getFileUpload().getId());
		}
	}

	public void convertToPersist(com.vietnam.power.persitence.Article art) {
		art.setName(this.name);
		art.setKeyword(this.keyword);
		art.setDescription(this.description);
		art.setEmbededMap(this.embededMap);
		art.setShortDescription(this.shortDescription);
		art.setArticleGroup(new ArticleGroup(this.articelGroupId));
		art.setEmail(this.email);
		art.setPassword(this.password);
	}
}